package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.MallCategoryDO;
import com.starlink.model.request.MallCategoryRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface MallCategoryMapper extends BaseMapper<MallCategoryDO> {
    MallCategoryDO selectDOById(Long id);
    List<MallCategoryDO> selectDOList(MallCategoryDO mallCategory);
    int insertDO(MallCategoryDO mallCategory);
    int batchInsertDO(List<MallCategoryDO> mallCategoryDOList);
    int updateDO(MallCategoryDO mallCategory);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from mall_category",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") MallCategoryRequest param);
    @Select({"<script>",
            "   select * from mall_category",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<MallCategoryDO> pageQuery(@Param("param") MallCategoryRequest param, @Param("limit") int limit, @Param("offset") long offset);
}
